import Vue from "vue";
import VueRouter from "vue-router";
import HomeView from "../views/HomeView.vue";
import MineView from "../views/MineView.vue";
import PunchView from "../views/PunchView.vue";
import RecordsView from "../views/RecordsView.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "home",
    component: HomeView,
    meta: { title: '首页' }
  },
  {
    path: "/punch",
    name: "punch",
    component: PunchView,
    meta: { title: '质量问题上报' }
  },
  {
    path: "/records",
    name: "records",
    component: RecordsView,
    meta: { title: '上报记录' }
  },
  {
    path: "/mine",
    name: "mine",
    component: MineView,
    meta: { title: '个人中心' }
  }
];

const router = new VueRouter({
  routes,
});

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '石油管道工程质检系统';
  next();
});

export default router;
